<template>
    <fieldset>
        <legend>列表</legend>
        <ul>
            <li v-for=" item in products" :key="item.productId">
                <router-link :to="`/detail/${item.productId}`">
                <img :src="listImg(item)" height="50" alt="">
                {{item.productName}}</router-link>
            </li>
        </ul>
    </fieldset>
</template>

<script>
let regExp = /(?<=imgurl=)[^'"]*/;
    export default {
        data(){
            return {
                products:[],
            }
        },
        mounted(){
            fetch('http://chst.vip:1234/api/getmoneyctrl')
            .then(body=>body.json())
            .then(res=>{
                console.log(res)
                this.products = res.result
                console.log(this.products);
            })
        },
        methods:{
            listImg(item){
                console.log(item.productImg2);
                return regExp.exec(item.productImg2)[0]
            }
            
        }

    }
</script>